package gl.drawer

import gl.window
import org.lwjgl.glfw.GLFW
import org.lwjgl.opengl.GL11

abstract class Drawer {

    protected open val name: CharSequence get() = javaClass.simpleName

    abstract fun initialize()

    open fun handleKey(keyCode: Int, action: Int) {}

    open fun resume() {
        GLFW.glfwSetWindowTitle(window.windowId, name)
    }

    open fun update(): Boolean {
        GL11.glClear(GL11.GL_COLOR_BUFFER_BIT or GL11.GL_DEPTH_BUFFER_BIT or GL11.GL_STENCIL_BUFFER_BIT)
        return false
    }

    open fun stop() { }

    abstract fun terminal();

    open fun onResize(width: Int, height: Int) {}

    var isInitialized = false
}